package variable;

import java.util.Scanner;

public class Retirement {
    public static void main(String[] args) {
        //read input
        Scanner in = new Scanner(System.in);
        System.out.println("how much do you need for retire?");
        double goal = in.nextDouble();
        System.out.println("how much will you contribute for retirement every year");
        double payment = in.nextDouble();
        System.out.println("Interest rate in %:");
        double rate = in.nextDouble();

        double balance = 0;
        int year = 0;
        while (balance < goal){
            balance = (1+rate)*balance + payment;
            System.out.println(balance);
            year++;
        }
        System.out.println("you can retire in "+year+" years");
    }
}
